#ifndef __WED_PHY_YT8512H_H__
#define __WED_PHY_YT8512H_H__

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "dev/phy/Wed_phy.h"
#include "kernel/Wed_clock.h"

/* \brief PHY 设备 ID */
#define YT8512H_ID                   0x128
#define YT8512H_LED0                 0
#define YT8512H_LED1                 3
#define YT8512_EXTREG_LED0           0x40c0
#define YT8512_EXTREG_SLEEP_CONTROL1 0x2027
#define YT8512_LED0_DIS_LED_AN_TRY   0x0001
#define YT8512_LED_BT_BLK_EN         0x0002
#define YT8512_LED_HT_BLK_EN         0x0004
#define YT8512_LED_COL_BLK_EN        0x0008
#define YT8512_LED_BT_ON_EN          0x0010
#define YT8512_LED_HT_ON_EN          0x0020
#define YT8512_LED_RXACT_BLK_EN      0x0100
#define YT8512_LED_TXACT_BLK_EN      0x0200
#define YT8512_LED_ACT_BLK_IND       0x1000

#define YT8512H_REG_SPEC_STATUS      0x11
#define YT8512H_EXT_REG_OFFSET       0x1e
#define YT8512H_EXT_REG_DATA         0x1f

#define YT8512_EN_SLEEP_SW_BIT       15

#define YT8512H_PHY_LINK_SPEED          (3 << 14)
#define YT8512H_PHY_LINK_SPEED_10       (0 << 14)
#define YT8512H_PHY_LINK_SPEED_100      (1 << 14)
#define YT8512H_PHY_LINK_SPEED_1000     (2 << 14)

#define YT8512H_PHY_LINK_STATUS         (1 << 10)
#define YT8512H_PHY_LINK_DUPLEX         (1 << 13)
#define YT8512H_PHY_LINK_DUPLEX_FULL    (1 << 13)
#define YT8512H_PHY_LINK_DUPLEX_HALF    (0 << 13)


/**
 * \brief PHY YT8512 ID 检查
 *
 * @param p_phy    PHY 设备名字
 * @param phy_addr PHY 设备地址
 *
 * @return 成功返回 0
 */
int Wed_phy_yt8512h_id_chk(struct Wed_phy *p_phy, int phy_addr);
/**
 * \brief PHY YT8512 链接灯设置
 *
 * @param p_phy    PHY 设备名字
 * @param phy_addr PHY 设备地址
 * @param led_idx  灯索引
 *
 * @return 成功返回 0
 */
int Wed_phy_yt8512h_link_led_set(struct Wed_phy *p_phy,
                                 int             phy_addr,
                                 int             led_idx);
/**
 * \brief PHY YT8512 激活灯设置
 *
 * @param p_phy    PHY 设备名字
 * @param phy_addr PHY 设备地址
 * @param led_idx  灯索引
 *
 * @return 成功返回 0
 */
int Wed_phy_yt8512h_active_led_set(struct Wed_phy *p_phy,
                                   int             phy_addr,
                                   int             led_idx);
/**
 * \brief PHY YT8512 休眠控制
 *
 * @param p_phy    PHY 设备名字
 * @param phy_addr PHY 设备地址
 *
 * @return 成功返回 0
 */
int Wed_phy_yt8512h_sleep_control(struct Wed_phy *p_phy,
                                  int             phy_addr);
/**
 * \brief PHY YT8512 状态获取
 *
 * @param p_phy    PHY 设备名字
 * @param phy_addr PHY 设备地址
 *
 * @return 成功返回 0
 */
int Wed_phy_yt8512h_status_get(struct Wed_phy *p_phy,
                               int             phy_addr);
#endif
